/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package studenttrack.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Temporal;
import stException.WrongOldPasswordException;

/**
 *
 * @author tg227
 */
@Entity
public class Student implements StudentInterface {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private String id;

    public String getEmailID() {
        return id;
    }

    public void setEmailID(String emailID) {
        this.id = emailID;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Student)) {
            return false;
        }
        Student other = (Student) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "studenttrack.entity.Student[id=" + id + "]";
    }

    //end gen code

        private String name;
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date dob;
    private String candidateNumber;
    private String studentNumber;
    private String emailID;
    private String password;
    //TO-DO: add attributes for course, moduleList and submission (not added straightaway because classes don't exist yet.)

    public void setPassword(String oldPass, String newPass) throws WrongOldPasswordException{
        if(oldPass.equals(password)) {
            password = newPass;
        } else {
            throw new WrongOldPasswordException();
        }
    }

    public String getCandidateNumber() {
        return candidateNumber;
    }

    public void setCandidateNumber(String candidateNumber) {
        this.candidateNumber = candidateNumber;
    }

    public Date getDob() {
        return dob;
    }

    public void setDob(Date dob) {
        this.dob = dob;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getStudentNumber() {
        return studentNumber;
    }

    public void setStudentNumber(String studentNumber) {
        this.studentNumber = studentNumber;
    }


}
